﻿using System.Drawing;
using MINERP.COM;
using MINERP.MODEL.NewPinBan;

namespace MINERP.BLL.NewPB
{
    public class MyRectangle
    {
        public MyRectangle(int inbarcodeWidth)
        {
            BARCODEWIDTH = inbarcodeWidth;
        }
        int BARCODEWIDTH = 30;
        public MyRectangle(PhotoInfo_PinBan inPhoto, int inBarCodeWidth)
        {
            this.BARCODEWIDTH = inBarCodeWidth;
            myPhoto = inPhoto;
            if (inPhoto.BarCodeStatus == (int)PhotoBarCodeStatus.RightOrLeft)
            {
                if (inPhoto.IsWhirl)
                {
                    Size size = new Size((inPhoto.PixFactHeigth + BARCODEWIDTH), inPhoto.PixFactWidth);
                    this.myRact = new Rectangle(inPhoto.Location, size);
                }
                else
                {
                    Size size = new Size((inPhoto.PixFactWidth + BARCODEWIDTH), inPhoto.PixFactHeigth);
                    this.myRact = new Rectangle(inPhoto.Location, size);
                }
            }
            else if (inPhoto.BarCodeStatus == (int)PhotoBarCodeStatus.TopOrBottom)
            {
                if (Photo.IsWhirl)
                {
                    Size size = new Size((inPhoto.PixFactHeigth), inPhoto.PixFactWidth + BARCODEWIDTH);
                    this.myRact = new Rectangle(inPhoto.Location, size);
                }
                else
                {
                    Size size = new Size((inPhoto.PixFactWidth), inPhoto.PixFactHeigth + BARCODEWIDTH);
                    this.myRact = new Rectangle(inPhoto.Location, size);
                }
            }
            else
            {
                if (Photo.IsWhirl)
                {
                    Size size = new Size((inPhoto.PixFactHeigth), inPhoto.PixFactWidth);
                    this.myRact = new Rectangle(inPhoto.Location, size);
                }
                else
                {
                    Size size = new Size((inPhoto.PixFactWidth), inPhoto.PixFactHeigth);
                    this.myRact = new Rectangle(inPhoto.Location, size);
                }
            }
            //Size size = new Size(inPhoto.Photo_Base_Info.PixFactWidth, inPhoto.Photo_Base_Info.PixFactHeigth);
            //this.myRact = new Rectangle(inPhoto.Location, size);

        }
        public MyRectangle(Rectangle rant, int inbarcodeWidth)
        {
            this.myRact = rant;
            this.BARCODEWIDTH = inbarcodeWidth;
        }
        private Rectangle myRact { get; set; }
        private PhotoInfo_PinBan myPhoto { get; set; }
        public PhotoInfo_PinBan Photo { get { return myPhoto; } }
        public Rectangle PRactangle { get { return this.myRact; } }//当前块
        public bool isUsefull { get; set; }//是否包含照片
        public double Areas { get { return myRact.Width * myRact.Height; } }
        //public MyRectangle LeftRect { get; set; }
        //public MyRectangle RightRect { get; set; }
        //public MyRectangle TopRect { get; set; }
        //public MyRectangle Bottom { get; set; }
        public Point LeftTopPoint { get { return myRact.Location; } }
        public Point RighTopPoint { get { return new Point(myRact.Location.X + myRact.Width, myRact.Location.Y); } }
        public Point LeftBottomPoint { get { return new Point(myRact.Location.X, myRact.Location.Y + myRact.Height); } }
        public Point RightBottomPoint { get { return new Point(myRact.Location.X + myRact.Width, myRact.Location.Y + myRact.Height); } }
    }
}